package config

import (
	"github.com/spf13/viper"
)

type Config struct {
	Ethereum Ethereum
	Server   Server
	DB       DB
}

type Ethereum struct {
	HexKey string
	WS     string
}

type Server struct {
	Host string
	Port uint
}

type DB struct {
	DSN string
}

func New(configFile string) Config {
	var cfg Config
	viper.SetConfigFile(configFile)
	if err := viper.ReadInConfig(); err != nil {
		panic(err)
	}
	if err := viper.Unmarshal(&cfg); err != nil {
		panic(err)
	}
	return cfg
}
